//
//  IsValidateOrNot.m
//  TaiHao
//
//  Created by rzm on 16/6/2.
//  Copyright © 2016年 rzm. All rights reserved.
//

#import "IsValidateOrNot.h"

@implementation IsValidateOrNot
+ (BOOL) isValidateMobile:(NSString *)mobile
{
    //手机号以13， 15，18开头，八个 \d 数字字符
//    NSString *phoneRegex = @"^((13[0-9])|(15[^4,\\D])|(18[0,0-9]))\\d{8}$";
    //手机号以13， 15，18,17开头，八个 \d 数字字符

    NSString *phoneRegex = @"^1[3|4|5|7|8][0-9]\\d{8}$";

    NSPredicate *phoneTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",phoneRegex];
    //    NSLog(@"phoneTest is %@",phoneTest);
    return [phoneTest evaluateWithObject:mobile];
}

/**
 *  邮箱验证是否有效
 *
 *  @param email 邮箱
 *
 *  @return bool
 */
+ (BOOL)isValidateEmail:(NSString *)email
{
    NSString *emailRegex = @"[A-Z0-9a-z._%+-]+@[A-Za-z0-9.-]+\\.[A-Za-z]{2,4}";
    NSPredicate *emailTest = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", emailRegex];
    return [emailTest evaluateWithObject:email];
}
/**
 *  验证密码是否有效
 *
 *  @param passWord 密码
 *
 *  @return bool
 */
+ (BOOL)isValidatePassword:(NSString *)passWord
{
    NSString *passWordRegex = @"^[0-9a-zA-Z_]{7,16}$";
    NSPredicate *passWordPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",passWordRegex];
    return [passWordPredicate evaluateWithObject:passWord];
}


+ (BOOL) isValidateAccount:(NSString *)account
{
    //手机号以13， 15，18开头，八个 \d 数字字符
    NSString *accountRegex = @"^[0-9a-zA-Z_]{7,16}$";
    NSPredicate *accountPredicate = [NSPredicate predicateWithFormat:@"SELF MATCHES %@",accountRegex];
    return [accountPredicate evaluateWithObject:account];
}

@end
